<template>
  <div>
    <!-- 首页 -->
    <form action="/">
      <van-nav-bar class="search">
        <template #right>
          <van-search
            v-model="value"
            placeholder="请输入搜索关键词"
            @search="onSearch"
            @cancel="onCancel"
            input-align="center"
          >
            <template #left>
              <van-button
                type="primary"
                to="/listsOfCities"
                color="#969799"
                plain
              >
              上海
              </van-button>
            </template>
          </van-search>
          <van-button round type="primary" size="mini" to="/findRoomMap">
            <van-icon name="location-o" color="#fff" size="25px"/>
          </van-button>
        </template>
      </van-nav-bar>
    </form>
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item
        ><img src="http://liufusong.top:8080/img/swiper/1.png" alt=""
      /></van-swipe-item>
      <van-swipe-item
        ><img src="http://liufusong.top:8080/img/swiper/2.png" alt=""
      /></van-swipe-item>
      <van-swipe-item
        ><img src="http://liufusong.top:8080/img/swiper/3.png" alt=""
      /></van-swipe-item>
    </van-swipe>
    <!-- 功能 -->
    <van-grid clickable :column-num="4" :border="false">
      <van-grid-item icon="wap-home-o" text="整租" to="/lookForHousing">
      </van-grid-item>
      <van-grid-item icon="friends-o" text="合租" to="/lookForHousing">
      </van-grid-item>
      <van-grid-item icon="guide-o" text="地图找房" to="/findRoomMap">
      </van-grid-item>
      <van-grid-item icon="home-o" text="去出租" to="/publishListings">
      </van-grid-item>
    </van-grid>
    <!-- 租房小组 -->
    <div class="rentalGroup">
      <h3>租房小组 <span class="more">更多</span></h3>
      <van-grid
        :border="false"
        :column-num="2"
        gutter="10"
        direction="horizontal"
      >
        <van-grid-item>
          <van-image src="https://img01.yzcdn.cn/vant/apple-1.jpg" />
          <div>
            <p>家住回龙观</p>
            <p>归属的感觉</p>
          </div>
        </van-grid-item>
        <van-grid-item>
          <van-image src="https://img01.yzcdn.cn/vant/apple-2.jpg" />
          <div>
            <p>家住回龙观</p>
            <p>归属的感觉</p>
          </div>
        </van-grid-item>
        <van-grid-item>
          <van-image src="https://img01.yzcdn.cn/vant/apple-3.jpg" />
          <div>
            <p>家住回龙观</p>
            <p>归属的感觉</p>
          </div>
        </van-grid-item>
        <van-grid-item>
          <van-image src="https://img01.yzcdn.cn/vant/apple-4.jpg" />
          <div>
            <p>家住回龙观</p>
            <p>归属的感觉</p>
          </div>
        </van-grid-item>
      </van-grid>
    </div>
  </div>
</template>
<script>
import { Toast } from 'vant'

export default {
  name: 'HomePage',
  data () {
    return {
      value: ''
    }
  },
  computed: {},
  watch: {},
  methods: {
    onSearch (val) {
      Toast(val)
    },
    onCancel () {
      Toast('取消')
    }
  }
}
</script>

<style scoped lang="less">
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  height: 212px;
  text-align: center;
  background-color: #39a9ed;
}
.my-swipe img {
  width: 100%;
  height: 100%;
}
::v-deep form {
  position: fixed;
  top: 25px;
  left: 0;
  z-index: 2;
  width: 100%;
  background-color: rgb(251, 250, 250, 0.1);
  .van-search {
    background: transparent;
    padding: 0, 10px;
  }
}
::v-deep .van-nav-bar {
  position: fixed;
  top: 25px;
  left: 0;
  z-index: 999;
  width: 100%;
  // background-color: rgb(251, 250, 250, .1);
  padding: 0 10px;
  background: transparent;
  ::v-deep .van-nav-bar__title {
    width: 1px;
  }
  .van-nav-bar__right {
    display: flex;
    justify-content: space-between;
    width: 375px;
    margin: 0, 10px;
    .van-search {
      width: 310px;
      margin-left: 10px;
      .van-button--primary {
        height: 35px;
        width: 50px;
        border-width: 0;
      }
    }
    .van-button--primary {
      background: transparent;
      border-width: 0;
    }
  }
}
.rentalGroup {
  width: 100%;
  height: 188px;
  // background-color: red;
  background-color: #f6f5f6;
  h3 {
    margin-top: 10px;
    position: relative;
    width: 345px;
    // margin: 15px 0 15px 10px;
    padding: 10px 0 1px 10px;
    font-size: 15px;
    .more {
      color: #787d82;
      position: absolute;
      right: 0;
      font-size: 14px;
      font-weight: 400;
    }
  }
  .van-grid-item {
    width: 172px;
    height: 50px;
    // background-color: #ffffff;
    font-size: 14px;
    .van-image {
      width: 50px;
      height: 50px;
      margin: 0 10px;
    }
  }
}
</style>
